<?php


namespace app\api\controller;
use think\facade\Db;

class Tinymce
{

    /**
     * 上传图片
     * $fileType 限制上传类型
     * $size（B） 限制上传大小 1 M = 1048576 B
    **/
    public function uploadImage(){
        $size = 1048576;
        $fileType = "jpg,jpeg,png,bmp,gif";
        $image = fileUpload($size,$fileType);
        return json($image);
    }
    /**
     * 上传媒体文件
     * $fileType 限制上传类型
     * $size（B） 限制上传大小 10 M = 10485760 B
     **/
    public function uploadMedium(){
        $size = 10485760;
        $fileType = "mp3,mp4";
        $medium = fileUpload($size,$fileType);
        return json($medium);
    }
    public function getTinymce(){
        /**
        CREATE TABLE `tinymce` (
        `tinymce_id` int(11) NOT NULL,
        `tinymce_content1` text NOT NULL,
        `tinymce_content2` text NOT NULL,
        `tinymce_time` datetime NOT NULL,
         PRIMARY KEY (`tinymce_id`)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

        --
        -- 转存表中的数据 `tinymce`
        --

        INSERT INTO `tinymce` (`tinymce_id`, `tinymce_content1`, `tinymce_content2`, `tinymce_time`) VALUES
        (1, 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAA', 'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB', '2022-11-12 15:39:46');

         **/
        $tinymce = Db::table('tinymce')->where('tinymce_id',1)->find();
        return json(['status'=>200,'data'=>$tinymce]);
    }

    public function updateTinymce(){
        $data = request()->param();
        $tinymce = Db::table('tinymce')->where('tinymce_id',1)->update($data);
        if($tinymce)success('更新');else fail('更新');
    }

}